package com.probiz.estore.common.model.product.base;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

import com.probiz.estore.common.model.inventory.Inventory;
import com.probiz.estore.common.model.product.Product;
import com.probiz.estore.common.model.product.ProductPackageItem;
import com.probiz.estore.common.model.product.ProductSkuOptionValue;
import com.probiz.estore.common.model.product.ProductStat;
import com.probiz.estore.common.model.product.SkuOptionValue;
import com.probiz.estore.common.model.product.WholesalePrice;
import com.probiz.estore.core.model.BaseObject;

/**
 * ProductSku Base Java Bean, base class for the model, mapped directly to database table
 * <p/>
 * Avoid changing this file if not necessary, will be overwritten.
 */
public class ProductSkuTbl extends BaseObject implements Serializable {

    protected Integer productSkuId;
    protected String productSkuCode;
    protected BigDecimal weight;
    protected BigDecimal length;
    protected BigDecimal width;
    protected BigDecimal height;
    protected String imageUrl;
    protected BigDecimal price;
    protected BigDecimal salePrice;
    protected BigDecimal listPrice;
    protected String skuOptionValueInfo;
    protected java.util.Date createTime;
    protected java.util.Date updateTime;
    protected Integer version;
    protected Integer sortOrder;
    protected Short status;
    protected ProductStat productStat;
    protected Product product;
    protected Inventory inventory;
        
    protected Set<ProductPackageItem> productPackageItems = new HashSet<ProductPackageItem>();
    protected Set<ProductSkuOptionValue> productSkuOptionValues = new HashSet<ProductSkuOptionValue>();
    protected Set<WholesalePrice> wholesalePrices = new HashSet<WholesalePrice>();
    
    //用于导入批发价时候使用
    protected List<WholesalePrice> importWholesalePrices = new ArrayList<WholesalePrice>();
    //导入规格字符串
    protected String importSkuOptionValueInfo = "";
    //导入的规格项值
    protected List<SkuOptionValue> importSkuOptionValueList = new ArrayList<SkuOptionValue>();


    /**
     * Default Empty Constructor for class ProductSku
     */
    public ProductSkuTbl() {
        super();
    }

    /**
     * Default Key Fields Constructor for class ProductSku
     * @param in_productSkuId SKU id
     */
    public ProductSkuTbl(Integer in_productSkuId) {
        this.setProductSkuId(in_productSkuId);
    }


    public Product getProduct() {
        return product;
    }

    public void setProduct(Product product) {
        this.product = product;
    }

  
    public Set<ProductPackageItem> getProductPackageItems() {
        return productPackageItems;
    }

    public void setProductPackageItems(Set<ProductPackageItem> productPackageItems) {
        this.productPackageItems = productPackageItems;
    }

    public Set<ProductSkuOptionValue> getProductSkuOptionValues() {
        return productSkuOptionValues;
    }

    public void setProductSkuOptionValues(Set<ProductSkuOptionValue> productSkuOptionValues) {
        this.productSkuOptionValues = productSkuOptionValues;
    }

    public Inventory getInventory() {
		return inventory;
	}

	public void setInventory(Inventory inventory) {
		this.inventory = inventory;
	}
	
	 public Integer getInventoryId() {
	        return this.getInventory() == null ? null : this.getInventory().getInventoryId();
	    }

    public void setInventoryId(Integer aValue) {
        if (aValue == null) {
            inventory = null;
        } else {
        	inventory = new Inventory(aValue);
        	inventory.setVersion(Integer.valueOf(0));//set a version to cheat hibernate only
        }
    }
    public Set<WholesalePrice> getWholesalePrices() {
        return wholesalePrices;
    }

    public void setWholesalePrices(Set<WholesalePrice> wholesalePrices) {
        this.wholesalePrices = wholesalePrices;
    }
    

    public List<WholesalePrice> getImportWholesalePrices() {
		return importWholesalePrices;
	}

	public void setImportWholesalePrices(List<WholesalePrice> importWholesalePrices) {
		this.importWholesalePrices = importWholesalePrices;
	}

	public String getImportSkuOptionValueInfo() {
		return importSkuOptionValueInfo;
	}

	public void setImportSkuOptionValueInfo(String importSkuOptionValueInfo) {
		this.importSkuOptionValueInfo = importSkuOptionValueInfo;
	}

	
	public List<SkuOptionValue> getImportSkuOptionValueList() {
		return importSkuOptionValueList;
	}

	public void setImportSkuOptionValueList(
			List<SkuOptionValue> importSkuOptionValueList) {
		this.importSkuOptionValueList = importSkuOptionValueList;
	}

	/**
     * * @return Integer
     *
     * @hibernate.id column="productSkuId" type="java.lang.Integer" generator-class="native"
     */
    public Integer getProductSkuId() {
        return this.productSkuId;
    }

    /**
     * Set the productSkuId
     */
    public void setProductSkuId(Integer aValue) {
        this.productSkuId = aValue;
    }

    /**
     * * @return Integer
     */
    public Integer getProductId() {
        return this.getProduct() == null ? null : this.getProduct().getProductId();
    }

    /**
     * Set the productId
     */
    public void setProductId(Integer aValue) {
        if (aValue == null) {
            product = null;
        } else {
            product = new com.probiz.estore.common.model.product.Product(aValue);
            product.setVersion(Integer.valueOf(0));//set a version to cheat hibernate only
        }
    }

    /**
     * * @return String
     *
     * @hibernate.property column="productSkuCode" type="java.lang.String" length="32" not-null="true" unique="false"
     */
    public String getProductSkuCode() {
        return this.productSkuCode;
    }

    /**
     * Set the productSkuCode
     *
     * @spring.validator type="required"
     */
    public void setProductSkuCode(String aValue) {
        this.productSkuCode = aValue;
    }

    /**
     * * @return java.math.BigDecimal
     *
     * @hibernate.property column="weight" type="java.math.BigDecimal" length="12" not-null="false" unique="false"
     */
    public java.math.BigDecimal getWeight() {
        return this.weight;
    }

    /**
     * Set the weight
     */
    public void setWeight(java.math.BigDecimal aValue) {
        this.weight = aValue;
    }

    /**
     * * @return java.math.BigDecimal
     *
     * @hibernate.property column="length" type="java.math.BigDecimal" length="12" not-null="false" unique="false"
     */
    public java.math.BigDecimal getLength() {
        return this.length;
    }

    /**
     * Set the length
     */
    public void setLength(java.math.BigDecimal aValue) {
        this.length = aValue;
    }

    /**
     * * @return java.math.BigDecimal
     *
     * @hibernate.property column="width" type="java.math.BigDecimal" length="12" not-null="false" unique="false"
     */
    public java.math.BigDecimal getWidth() {
        return this.width;
    }

    /**
     * Set the width
     */
    public void setWidth(java.math.BigDecimal aValue) {
        this.width = aValue;
    }

    /**
     * * @return java.math.BigDecimal
     *
     * @hibernate.property column="height" type="java.math.BigDecimal" length="12" not-null="false" unique="false"
     */
    public java.math.BigDecimal getHeight() {
        return this.height;
    }

    /**
     * Set the height
     */
    public void setHeight(java.math.BigDecimal aValue) {
        this.height = aValue;
    }

    public String getImageUrl() {
        return imageUrl;
    }

    public void setImageUrl(String imageUrl) {
        this.imageUrl = imageUrl;
    }

    /**
     * 售价	 * @return java.math.BigDecimal
     *
     * @hibernate.property column="price" type="java.math.BigDecimal" length="12" not-null="true" unique="false"
     */
    public java.math.BigDecimal getPrice() {
        return this.price;
    }

    /**
     * Set the price
     *
     * @spring.validator type="required"
     */
    public void setPrice(java.math.BigDecimal aValue) {
        this.price = aValue;
    }

    /**
     * 特价	 * @return java.math.BigDecimal
     *
     * @hibernate.property column="salePrice" type="java.math.BigDecimal" length="12" not-null="false" unique="false"
     */
    public java.math.BigDecimal getSalePrice() {
        return this.salePrice;
    }

    /**
     * Set the salePrice
     */
    public void setSalePrice(java.math.BigDecimal aValue) {
        this.salePrice = aValue;
    }

    /**
     * 市场价格	 * @return java.math.BigDecimal
     *
     * @hibernate.property column="listPrice" type="java.math.BigDecimal" length="12" not-null="false" unique="false"
     */
    public java.math.BigDecimal getListPrice() {
        return this.listPrice;
    }

    /**
     * Set the listPrice
     */
    public void setListPrice(java.math.BigDecimal aValue) {
        this.listPrice = aValue;
    }

    /**
     * * @return java.util.Date
     *
     * @hibernate.property column="createTime" type="java.util.Date" length="0" not-null="true" unique="false"
     */
    public java.util.Date getCreateTime() {
        return this.createTime;
    }

    /**
     * Set the createTime
     *
     * @spring.validator type="required"
     */
    public void setCreateTime(java.util.Date aValue) {
        this.createTime = aValue;
    }

    /**
     * * @return java.util.Date
     *
     * @hibernate.property column="updateTime" type="java.util.Date" length="0" not-null="true" unique="false"
     */
    public java.util.Date getUpdateTime() {
        return this.updateTime;
    }

    /**
     * Set the updateTime
     *
     * @spring.validator type="required"
     */
    public void setUpdateTime(java.util.Date aValue) {
        this.updateTime = aValue;
    }

    /**
     * * @return Integer
     *
     * @hibernate.property column="version" type="java.lang.Integer" length="10" not-null="true" unique="false"
     */
    public Integer getVersion() {
        return this.version;
    }


    /**
     * Set the version
     *
     * @spring.validator type="required"
     */
    public void setVersion(Integer aValue) {
        this.version = aValue;
    }

    public Integer getSortOrder() {
        return sortOrder;
    }

    public void setSortOrder(Integer sortOrder) {
        this.sortOrder = sortOrder;
    }

  
    public String getSkuOptionValueInfo() {
		return skuOptionValueInfo;
	}

	public void setSkuOptionValueInfo(String skuOptionValueInfo) {
		this.skuOptionValueInfo = skuOptionValueInfo;
	}

	/**
     * * @return Short
     *
     * @hibernate.property column="status" type="java.lang.Short" length="5" not-null="true" unique="false"
     */
    public Short getStatus() {
        return this.status;
    }

    /**
     * Set the status
     *
     * @spring.validator type="required"
     */
    public void setStatus(Short aValue) {
        this.status = aValue;
    }

    /**
     * @see java.lang.Object#equals(Object)
     */
    public boolean equals(Object object) {
        if (!(object instanceof ProductSkuTbl)) {
            return false;
        }
        ProductSkuTbl rhs = (ProductSkuTbl) object;
        return new EqualsBuilder()
                .append(this.productSkuId, rhs.productSkuId)
                .append(this.productSkuCode, rhs.productSkuCode)
                .append(this.weight, rhs.weight)
                .append(this.length, rhs.length)
                .append(this.width, rhs.width)
                .append(this.height, rhs.height)
                .append(this.price, rhs.price)
                .append(this.salePrice, rhs.salePrice)
                .append(this.listPrice, rhs.listPrice)
                .append(this.createTime, rhs.createTime)
                .append(this.updateTime, rhs.updateTime)
                .append(this.version, rhs.version)
                .append(this.status, rhs.status)
                .isEquals();
    }

    /**
     * @see java.lang.Object#hashCode()
     */
    public int hashCode() {
        return new HashCodeBuilder(-82280557, -700257973)
                .append(this.productSkuId)
                .append(this.productSkuCode)
                .append(this.weight)
                .append(this.length)
                .append(this.width)
                .append(this.height)
                .append(this.price)
                .append(this.salePrice)
                .append(this.listPrice)
                .append(this.createTime)
                .append(this.updateTime)
                .append(this.version)
                .append(this.status)
                .toHashCode();
    }

    /**
     * @see java.lang.Object#toString()
     */
    public String toString() {
        return new ToStringBuilder(this)
                .append("productSkuId", this.productSkuId)
                .append("productSkuCode", this.productSkuCode)
                .append("weight", this.weight)
                .append("length", this.length)
                .append("width", this.width)
                .append("height", this.height)
                .append("price", this.price)
                .append("salePrice", this.salePrice)
                .append("listPrice", this.listPrice)
                .append("createTime", this.createTime)
                .append("updateTime", this.updateTime)
                .append("version", this.version)
                .append("status", this.status)
                .toString();
    }

    /**
     * Return the name of the first key column
     */
    public String getFirstKeyColumnName() {
        return "productSkuId";
    }

    /**
     * Return the Id (pk) of the entity, must be Integer
	 */
	public Integer getId() {
		return productSkuId;
	}

	public ProductStat getProductStat() {
		return productStat;
	}

	public void setProductStat(ProductStat productStat) {
		this.productStat = productStat;
	}
}